//
//  WBHomeOriginalView.swift
//  weiboD
//
//  Created by gao2015 on 2016/12/5.
//  Copyright © 2016年 gao2015. All rights reserved.
//

import UIKit

class WBHomeOriginalView: UIView {
    //用户头像
    private lazy var userImageView : UIImageView = UIImageView(image: UIImage(named: "avatar_default_big"))
    
    //用户认证类型
    private lazy var verifiedTypeImageView : UIImageView = UIImageView(image: UIImage(named: "avatar_enterprise_vip"))
    //MARK:采用闭包的形式添加额外属性
    //用户昵称
    private lazy var nameLabel : UILabel = {
        let label = UILabel()
        label.text = "小红帽"
        label.textColor = UIColor.darkGray
        label.font = UIFont.systemFont(ofSize: 14)
        return label
    }()
    
    //会员等级view
    private lazy var mbankImageView : UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_expired"))
    
    //发布时间
    
    private lazy var timeLabel : UILabel = {
        let label = UILabel()
        label.text = "刚刚"
        label.textColor = UIColor.orange
        label.font = UIFont.systemFont(ofSize: 13)
        return label
    }()
    
    //发布来源
    private lazy var sourceLabel : UILabel = {
        let label = UILabel()
        label.text = "来自:新浪微博"
        label.textColor = UIColor.lightGray
        label.font = UIFont.systemFont(ofSize: 13)
        return label
    }()
    
    
    //发布内容
    private lazy var textLabel : UILabel = {
        let label = UILabel()
        label.text = " 经济日报讯 记者朱琳报道：国台办发言人马晓光11月30日在例行新闻发布会上介绍大陆有关企业近期应台湾8县市邀请，考察洽商农产品采购情况时表示，由中华全国供销合作总社牵头组织大陆相关协会和企业，于11月21日至28日赴台考察、洽商农产品合作。"
        label.textColor = UIColor.darkGray
        label.font = UIFont.systemFont(ofSize: 14)
        label.numberOfLines = 0
        label.textAlignment = .center
        return label
    }()
    

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func setupUI(){
//        backgroundColor = randomColor()
        addSubview(userImageView)
        addSubview(verifiedTypeImageView)
        addSubview(nameLabel)
        addSubview(mbankImageView)
        addSubview(timeLabel)
        addSubview(sourceLabel)
        addSubview(textLabel)
        
        userImageView.snp_makeConstraints { (make) in
            make.top.left.equalTo(self).offset(10)
            make.size.equalTo(CGSize(width: 35, height: 35))
        }
        
        verifiedTypeImageView.snp_makeConstraints { (make) in
            make.centerX.equalTo(userImageView.snp_right)
            make.centerY.equalTo(userImageView.snp_bottom)
        }
        
        nameLabel.snp_makeConstraints { (make) in
            make.left.equalTo(userImageView.snp_right).offset(10)
            make.top.equalTo(userImageView)
        }
        
        mbankImageView.snp_makeConstraints { (make) in
            make.left.equalTo(nameLabel.snp_right).offset(10)
            make.top.equalTo(nameLabel)
        }
        
        timeLabel.snp_makeConstraints { (make) in
            make.left.equalTo(nameLabel)
            make.top.equalTo(nameLabel.snp_bottom).offset(10)
        }
        
        sourceLabel.snp_makeConstraints { (make) in
            make.left.equalTo(timeLabel.snp_right).offset(10)
            make.top.equalTo(timeLabel)
        }
        
        textLabel.snp_makeConstraints { (make) in
            make.left.equalTo(self).offset(10)
            make.top.equalTo(userImageView.snp_bottom).offset(15)
            make.right.equalTo(self).offset(-10)
        }
    
    }
}
